/**
 * Copyright © 2008, EMC Corporation.
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 *     + Redistributions of source code must retain the above copyright notice, 
 *       this list of conditions and the following disclaimer.
 *     + Redistributions in binary form must reproduce the above copyright 
 *       notice, this list of conditions and the following disclaimer in the 
 *       documentation and/or other materials provided with the distribution.
 *     + The name of EMC Corporation may not be used to endorse or promote 
 *       products derived from this software without specific prior written 
 *       permission.
 *
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 *      TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 *      PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
 *      BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *      CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *      SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 *      INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 *      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 *      POSSIBILITY OF SUCH DAMAGE.
 */
package com.emc.esu.api {
	import flash.utils.Dictionary;
	
	/**
 	 * The MetadataTags class contains a collection of metadata tags
 	 * indexed by name.
 	 */
	public class MetadataTags {
	    private var tags:Dictionary = new Dictionary();
	    
	    /**
	     * Adds a tag to the set of tags
	     * @param tag the tag to add
	     */
	    public function addTag( tag:MetadataTag ):void {
	        tags[tag.getName()] = tag;
	    }
	    
	    /**
	     * Removes a tag from the set of tags
	     * @param tag the tag to remove
	     */
	    public function removeTag( tag:MetadataTag ):void {
	        delete tags[tag.getName()];
	    }
	    
	    /**
	     * Gets a tag from the set with the given name
	     * @param name the name to search for.
	     * @return the tag or null if this set does not contain a tag with the
	     * given name.
	     */
	    public function getTag( name:String ):MetadataTag {
	        return tags[ name ];
	    }
	    	    
	    /**
	     * Return true if this set contains the given tag object.
	     * @param tag the tag to search for.  May be a MetadataTag object or a String
	     * @return true if this set contains the given tag
	     */
	    public function contains( tag:Object ):Boolean {
	    	if( tag is MetadataTag ) {
	    		return tags[MetadataTag(tag).getName()] != null;
	    	} else {
	    		return tags[tag] != null;	
	    	}
	        
	    }
	
	    /**
	     * Returns the items in the tag list.
	     * @return the list's items.
	     */
	    public function items():Dictionary {
	        return tags;
	    }

	}
}